package org.tigr.htc.cmd;


/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import java.util.Map;

import org.tigr.antware.shared.command.ICommonCommand;
import org.tigr.antware.shared.command.events.CommandLifetimeLI;
import org.tigr.antware.shared.command.events.CommandRuntimeStatusLI;
import org.tigr.antware.shared.command.events.CommandStatusLI;
import org.tigr.antware.shared.command.events.FailureEvent;
import org.tigr.antware.shared.command.events.FinishEvent;
import org.tigr.antware.shared.command.events.InterruptEvent;
import org.tigr.antware.shared.command.events.ResumeEvent;
import org.tigr.antware.shared.command.events.StartEvent;
import org.tigr.antware.shared.command.events.SubmitEvent;
import org.tigr.antware.shared.command.events.SuspendEvent;


/**
 * The <b>ICommand</b> is the base command interface that all commands
 * must support to be a DCE command.  ICommand inherits from ICommonCommand
 * that is the shared.command package. To be a DCE command you must have
 * an id, state, type, name, and support the shared event listener stuff.
 * id, type and name comes from ICommonCommand.
 *
 */
public interface ICommand extends ICommonCommand {

    /**
     * <code>getState</code> get the current command state 
     *
     * @return a <code>CmdState</code> value
     */
    public CmdState getState();

    /**
     * <code>setEnv</code> set the environment for the command.
     *
     * @param pEnv a <code>Map</code> a map that hold the key-value pairs 
     * that specify the environment
     */
    public void setEnv(Map<String, String> pEnv);

    public String getSubmitURL();

    public void createCommand();

    public void updateCommand();
    
    
    public void setSubmitTime(long pSubmitTime);
    
    public long getSubmitTime();
    
    public void setStartTime(long pStartTime);
    
    public long getStartTime();
    
    public void setEndTime(long pEndTime);
    
    public long getEndTime();

    

    /* listener stuff */


    /**
     * Describe <code>addLifetimeListener</code> method here.
     *
     * @param pListen a <code>CommandLifetimeLI</code> value
     */
    public void addLifetimeListener(CommandLifetimeLI pListen);
    
    /**
     * Describe <code>removeLifetimeListener</code> method here.
     *
     * @param pListen a <code>CommandLifetimeLI</code> value
     */
    public void removeLifetimeListener(CommandLifetimeLI pListen);
    
    /**
     * Describe <code>addRuntimeStatusListener</code> method here.
     *
     * @param pListen a <code>CommandRuntimeStatusLI</code> value
     */
    public void addRuntimeStatusListener(CommandRuntimeStatusLI pListen);
    
    /**
     * Describe <code>removeRuntimeStatusListener</code> method here.
     *
     * @param pListen a <code>CommandRuntimeStatusLI</code> value
     */
    public void removeRuntimeStatusListener(CommandRuntimeStatusLI pListen);
    
    /**
     * Describe <code>addStatusListener</code> method here.
     *
     * @param pListen a <code>CommandStatusLI</code> value
     */
    public void addStatusListener(CommandStatusLI pListen);
    
    /**
     * Describe <code>removeStatusListener</code> method here.
     *
     * @param pListen a <code>CommandStatusLI</code> value
     */
    public void removeStatusListener(CommandStatusLI pListen);


    /**
     * Describe <code>fireSubmitEvent</code> method here.
     *
     * @param p_machine a <code>String</code> value
     */
    public void fireSubmitEvent(String p_machine, String pLog);
    
    /**
     * Describe <code>fireSubmitEvent</code> method here.
     *
     * @param pEvent a <code>SubmitEvent</code> value
     */
    public void fireSubmitEvent(SubmitEvent pEvent);
    
    /**
     * Describe <code>fireStartEvent</code> method here.
     *
     * @param pMachine a <code>String</code> value
     */
    public void fireStartEvent(String pMachine);
    
    /**
     * Describe <code>fireStartEvent</code> method here.
     *
     * @param pEvent a <code>StartEvent</code> value
     */
    public void fireStartEvent(StartEvent pEvent);
    
    /**
     * Describe <code>fireFinishEvent</code> method here.
     *
     * @param pFinishEv a <code>FinishEvent</code> value
     */
    public void fireFinishEvent(FinishEvent pFinishEv);
    
    /**
     * Describe <code>fireInterruptEvent</code> method here.
     *
     * @param pInterruptEv an <code>InterruptEvent</code> value
     */
    public void fireInterruptEvent(InterruptEvent pInterruptEv);
    
    /**
     * Describe <code>fireResumeEvent</code> method here.
     *
     * @param pResumeEv a <code>ResumeEvent</code> value
     */
    public void fireResumeEvent(ResumeEvent pResumeEv);
    
    /**
     * Describe <code>fireRestartEvent</code> method here.
     *
     * @param pStartEv a <code>StartEvent</code> value
     */
    public void fireRestartEvent(StartEvent pStartEv);
    
    /**
     * Describe <code>fireFailureEvent</code> method here.
     *
     * @param pFailureEv a <code>FailureEvent</code> value
     */
    public void fireFailureEvent(FailureEvent pFailureEv);
    
    /**
     * Describe <code>fireFailureEvent</code> method here.
     *
     * @param pE a <code>Throwable</code> value
     */
    public void fireFailureEvent(Throwable pE);
    
    /**
     * Describe <code>fireSuspendEvent</code> method here.
     *
     * @param pSuspendEv a <code>SuspendEvent</code> value
     */
    public void fireSuspendEvent(SuspendEvent pSuspendEv);
}
